package cn.lyjuan.android.mylibrary.util;

import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;

import cn.lyjuan.android.mylibrary.context.BaseApplication;

/**
 * 从资源文件中加载 id 指定的值
 * Created by chad on 04/11/2017.
 */

public class RsUtils
{
    public static Drawable drawable(int id)
    {
        return ContextCompat.getDrawable(BaseApplication.getContext(), id);
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
//            return BaseApplication.getContext().getDrawable(id);
//        else
//            return BaseApplication.getContext().getResources().getDrawable(id, BaseApplication.getContext().getTheme());
    }

    public static String string(int id)
    {
        return BaseApplication.getContext().getResources().getString(id);
    }

    public static int color(int id)
    {
        return ContextCompat.getColor(BaseApplication.getContext(), id);

//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
//            return BaseApplication.getContext().getColor(id);
//        else
//            return BaseApplication.getContext().getResources().getColor(id, BaseApplication.getContext().getTheme());
    }

    public static float dimen(int id)
    {
        return BaseApplication.getContext().getResources().getDimension(id);
    }
}
